package game.users.test;

import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import game.round.pojo.ARound;
import game.users.pojo.AUsers;
import game.users.service.IAUsersService;
import game.users.service.impl.AUsersServiceImpl;

public class AUsersServiceMain
{
	private IAUsersService usersService = new AUsersServiceImpl();
	/*添加一条信息*/
	private void insertOndAUsersService()
	{
		AUsers users = new AUsers();
		users.setNickName("王八蛋");
		users.setLevelId(2);
		users.setContent("下吧");
		users.setCreateTime(new Date());
		users.setUpdateTime(new Date());
		users.setPubTime(new Date());
		int res = this.usersService.insertService(users);
		System.out.println("=="+res);
		System.out.println("=="+users.getId());
	}
	/*查询一条信息*/
	private void findOndAUsersService()
	{
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("id", 2);
		AUsers users= this.usersService.findOndAUsersService(condMap);
		System.out.println("=="+users);
	}
	/*查询全部信息*/
	private void findCondListAUsersService()
	{
		Map<String, Object> condMap = new HashMap<String, Object>();
		/*存储结果*/
		List<AUsers> resultList = this.usersService.findCondListService(condMap);
		/*计数器*/
		int coun = 1;
		/*循环*/
		for (Iterator iterator = resultList.iterator(); iterator.hasNext();)
		{
			AUsers users = (AUsers) iterator.next();
			System.out.println(coun+"=="+users);
			coun ++; 
		}
	}
	/*更新一条信息*/
	private void updateOndAUsersService()
	{
		Map<String, Object> condMap = new HashMap<String, Object>();
		condMap.put("id", 2);
		AUsers users = this.usersService.findOndAUsersService(condMap);
		users.setEmail(users.getEmail()+2);
		users.setContent(users.getContent()+"明天");
		int res = this.usersService.updateService(users);
		System.out.println("=="+res);
	}
	public static void main(String[] args)
	{
		System.out.println("==");
		AUsersServiceMain  au = new AUsersServiceMain();
		//au.insertOndAUsersService();
		//au.findOndAUsersService();
		//au.findCondListAUsersService();
		//au.updateOndAUsersService();
	}

}
